package com.example.hilt.entity

import com.example.hilt.annotation.BindElectricEngine
import com.example.hilt.annotation.BindGasEngine
import com.example.hilt.callBack.Engine
import javax.inject.Inject

/**
 ********************************************************
 *Author: chinadragon
 *Time: 2023/9/7 09:52
 *Name:
 *Overview:
 *Usage:
 *
val修饰的变量类中会生成一个final的属性和对应的get方法；
var修饰变量类中也会生成对应的属性及get、set方法；
无val和var修饰的变量不会在类中生成属性，该变量只能在构造方法内使用。

 ********************************************************
 */
class Truck @Inject constructor(val driver: Driver) {
    @BindGasEngine
    @Inject
    lateinit var gasEngine: Engine

    @BindElectricEngine
    @Inject
    lateinit var electricEngine: Engine

    fun deliver() {
        gasEngine.start()
        electricEngine.start()
        println("Truck is delivering cargo. Driven by $driver")
        gasEngine.shutdown()
        electricEngine.shutdown()
    }
}